package com.wiloon.java8x.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * Created by wiloon on 3/26/17;
 */
public class CallableTest implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("线程执行中");
        return 0;
    }

    public static void main(String[] args) throws Exception {
        Callable<Integer> callable = new CallableTest();
        FutureTask<Integer> task = new FutureTask<>(callable);
        Thread thread = new Thread(task);
        System.out.println("start()方法调用前");
        thread.start();
        System.out.println("start()方法调用后");
        System.out.println("获取call方法的返回值：" + task.get());
    }
}
